<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:util="http://xmlns.jcp.org/jsf/composite/util"
                xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="groups_list_form">
        <util:dataTableWrapper title="Lista grupuri">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga grup nou"
                                 oncomplete="PF('add_group_WV').show()" update=":create_group_form"
                                 resetValues="true"
                                 actionListener="#{groupAdministrationBean.resetCreateUserGroupDialog}"/>
            </f:facet>

            <f:facet name="rightContent">
                <p:outputPanel layout="block">
                    <p:watermark for="search-input" value="cauta grup dupa nume"/>
                    <p:inputText id="search-input" style="width: 240px;margin-right: 5px"/>
                    <p:commandButton value="Cauta"/>
                </p:outputPanel>
            </f:facet>

            <p:dataTable id="groups_table" var="g" value="#{groupAdministrationBean.groups}"
                         emptyMessage="Nu a fost gasita nici o inregistrare."
                         paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

                <p:column headerText="Nume" sortBy="#{g.name}">
                    <h:outputText value="#{g.name}"/>
                </p:column>

                <p:column headerText="Descriere">
                    <h:outputText value="#{g.description}"/>
                </p:column>

                <p:column styleClass="override-icons"  headerText="Actions">
                    <p:commandButton icon="custom-icon-edit" value="Editeaza"
                                     actionListener="#{groupAdministrationBean.setSelectedUserGroup(g)}"
                                     oncomplete="PF('add_group_WV').show()" update=":create_group_form"/>
                    <p:commandButton icon="custom-icon-delete" value="Sterge"
                                     actionListener="#{groupAdministrationBean.deleteUserGroup(g)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea grupului selectat?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>
                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>
        <p:confirmDialog global="true">
            <p:commandButton value="Da" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
            <p:commandButton value="Nu" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
        </p:confirmDialog>
    </h:form>

</ui:composition>